import sys
import os

def showUsage() :
	print "Qt project and class easy creator 1.0"
	print "Usage:"
	print "qcreator project|class name"
	print ""

def createProject(projectName) :
	os.mkdir(projectName)
	os.chdir(projectName)
	mainFile = open("main.cpp", "w")
	mainFile.write("#include <QApplication>\n")
	mainFile.write("#include <QMainWindow>\n")
	mainFile.write("\n")
	mainFile.write("int main(int argc, char *argv[])\n")
	mainFile.write("{\n")
	mainFile.write("\tQApplication app(argc, argv);\n")
	mainFile.write("\n")
	mainFile.write("\tQMainWindow mw;\n")
	mainFile.write("\tmw.show();\n")
	mainFile.write("\n")
	mainFile.write("\tapp.exec();\n")
	mainFile.write("}\n")
	mainFile.close()		

def createClass(className) :
	print "Class Name: " + className
	cppFile = open(className + ".h", "w")
	cppFile.write("#pragma once\n")
	cppFile.write("\n")
	cppFile.write("class " + className + " : public QObject\n")
	cppFile.write("{\n")
	cppFile.write("\tQ_OBJECT\n")
	cppFile.write("public:\n")
	cppFile.write("\t" + className + "();\n")
	cppFile.write("\t~" + className + "();\n")
	cppFile.write("\n")
	cppFile.write("protected:\n")
	cppFile.write("\n")
	cppFile.write("private:\n")
	cppFile.write("\n")
	cppFile.write("};\n")
	cppFile.close();

	headerFile = open(className + ".cpp", "w")
	headerFile.write("#include <" + className + ".h>\n")
	headerFile.write("\n")
	headerFile.write(className + "::" + className + "()\n{\n}\n\n")
	headerFile.write(className + "::~" + className + "()\n{\n}\n\n")
	headerFile.close();
	
argc = len(sys.argv)
if argc < 2 : 
	showUsage()
	quit()

if sys.argv[1] == "project" :
	createProject(sys.argv[2])
elif sys.argv[1] == "class" :
	createClass(sys.argv[2])	
else :
	print "Wrong arguments!"
	quit()

